package priv.ljh.operate.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import priv.ljh.operate.entity.Order;
import priv.ljh.operate.service.OrderService;

import java.util.List;

/**
 * @author ：Yshuaong
 * @date ：Created in 2021/6/21 14:40
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
public class OrderController {
    @Autowired
    OrderService orderService;
    @RequestMapping("/getAllOrder")
    public List<Order> getAllOrder(@RequestParam("uid") int uid){
        System.out.println("订单");
        return orderService.getAllOrder(uid);
    }
    @RequestMapping("/insertOrder")
    public int insertOrder( @RequestParam("title")String title,
                         @RequestParam("number")int number,@RequestParam("img_url") String img_url,
                         @RequestParam("sell_price") String sell_price, @RequestParam("flag") int flag,
                         @RequestParam("uid") int uid){
        System.out.println("下单成功");
        return orderService.insertOrder( title,   number, img_url, sell_price, flag, uid);
    }
    @RequestMapping("/deleteOrder")
    public int deleteOrder(@RequestParam("oid") int oid){
        System.out.println("删除成功");
        return orderService.deleteOrder(oid);
    }
}
